﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using CuaHangLaptop.DAL;

namespace CuaHangLaptop.BIZ
{
    public class CTPhieuNhap_BIZ
    {
        int id;
        string maCTphieunhap;
        PhieuNhap_BIZ phieunhap = new PhieuNhap_BIZ();
        Laptop_BIZ laptop = new Laptop_BIZ();
        int soluong;

        public int ID
        {
            get { return id; }
            set { id = value; }
        }

        public string MaCTphieunhap
        {
            get { return maCTphieunhap; }
            set { maCTphieunhap = value; }
        }

        public PhieuNhap_BIZ Phieunhap
        {
            get { return phieunhap; }
            set { phieunhap = value; }
        }

        public Laptop_BIZ Laptop
        {
            get { return laptop; }
            set { laptop = value; }
        }

        public string TenLaptop
        {
            get { return laptop.TenLaptop; }
        }

        public int Soluong
        {
            get { return soluong; }
            set { soluong = value; }
        }

        public CTPhieuNhap_BIZ()
        {
        }

        public CTPhieuNhap_BIZ(int _id, string _ma, string _phieu, string _laptop, int _soluong)
        {
            id = _id;
            maCTphieunhap = _ma;
            phieunhap = phieunhap.Get_PhieuNhap_ByCode(_phieu);
            laptop = laptop.Get_Laptop_ByCode(_laptop);
            soluong = _soluong;
        }

        public List<CTPhieuNhap_BIZ> GetAll_CTPN_ByPN(string _MaCTPN)
        {
            return CTPhieuNhap_DAL.GetAll_CTPhieuNhap_ByPN(_MaCTPN);
        }

        public CTPhieuNhap_BIZ Get_CTPN_ByCode(string _MaCTPN)
        {
            return CTPhieuNhap_DAL.Get_CTPhieuNhap_ByCode(_MaCTPN);
        }

        public List<CTPhieuNhap_BIZ> GetAll_CTPhieuNhap()
        {
            return CTPhieuNhap_DAL.GetAll_CTPN();
        }

        public void Save()
        {
            if (id == -1) id = CTPhieuNhap_DAL.Insert(this);
            else CTPhieuNhap_DAL.Update(this);
        }

        public void Delete()
        {
            CTPhieuNhap_DAL.Delete(this);
        }

        public int Get_Lasted_ID()
        {
            return CTPhieuNhap_DAL.Get_Lasted_ID();
        }
    }
}
